{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 使用文生图数据集进行模型微调\n",
    "\n",
    "<span style=\"font-size: 20px; font-weight: bold;\">注意：您使用该案例默认的数据和模型训练时，会产生一定费用。计费方式参考：https://cloud.baidu.com/doc/WENXINWORKSHOP/s/6lrk4bgxb</span>\n",
    "\n",
    "在[trainer 发起finetune](./trainer_finetune.ipynb)中，我们已经学习了如何使用`trainer` + `dataset` 发起文生文微调任务，同时也体验了模型评估，批量推理，服务部署等流程；除了纯文本的生成模型外，千帆平台也提供了针对文心一格，以及开源的StableDiffusion模型的训练微调。\n",
    "\n",
    "\n",
    "本例将基于qianfan==0.3.6.1展示通过Dataset加载本地数据集，并上传到千帆平台，基于`Stable-Diffusion`进行fine-tune，以实现pokemon风格的图片生成能力。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "! pip install \"qianfan[dataset_base]>=0.3.0\" -U\n",
    "! pip install datasets==2.14.6 # huggingface datasets\n",
    "! pip install fsspec==2023.9.2 # fix load_dataset error"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0.3.6.1'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import qianfan\n",
    "qianfan.__version__"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 前置准备\n",
    "- 初始化千帆安全认证AK、SK"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os \n",
    "\n",
    "os.environ[\"QIANFAN_ACCESS_KEY\"] = \"your_ak\"\n",
    "os.environ[\"QIANFAN_SECRET_KEY\"] = \"your_sk\""
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 导入依赖\n",
    "- `qianfan.trainer.consts` trainer使用中所用到的常量\n",
    "- `qianfan.resources.console.consts` api层面定义的字段常量\n",
    "- `qianfan.trainer.configs` trainer使用所需要的config配置数据类\n",
    "- `qianfan.resources.QfMessages` 用于组装qianfan.ChatCompletion的输入messages\n",
    "- `qianfan.trainer.finetune.Finetune` 大语言模型fine-tune任务Trainer实现\n",
    "- `qianfan.dataset.Dataset` 千帆dataset类，用于管理千帆平台、本地、第三方数据集的导入导出，数据清洗等操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from qianfan.trainer.consts import ActionState\n",
    "from qianfan.model.consts import ServiceType\n",
    "from qianfan.resources.console import consts as console_consts\n",
    "from qianfan.trainer.configs import TrainConfig\n",
    "from qianfan.model.configs import DeployConfig\n",
    "from qianfan.resources import QfMessages\n",
    "from qianfan.trainer.finetune import Finetune\n",
    "from qianfan.dataset import Dataset\n",
    "from qianfan.utils import enable_log\n",
    "import logging\n",
    "\n",
    "enable_log(logging.INFO)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们此次选用huggingface的开源数据集用于生成pokemon风格的图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "b522df2ce1ce4eb38646e0fe047d8976",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Downloading data files:   0%|          | 0/1 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "4e3c1656009f473c870a0b32ebe05394",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Extracting data files:   0%|          | 0/1 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "e30c3aec641946e09dbc830c2c172d81",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Generating train split:   0%|          | 0/833 [00:00<?, ? examples/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 从huggingface 导入数据集：\n",
    "import datasets\n",
    "dataset = datasets.load_dataset(\"svjack/pokemon-blip-captions-en-zh\", split='train')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['image', 'en_text', 'zh_text']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset.column_names"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "将huggingface上的文生图数据集，增加指令，并转存成本地的数据集目录"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "\n",
    "pokemon_style_instruction = \"pokemon,\"\n",
    "save_ds_dir = \"./pokemon_ds\"\n",
    "if not os.path.exists(save_ds_dir):\n",
    "    os.mkdir(save_ds_dir)\n",
    "\n",
    "for i, v in enumerate(dataset):\n",
    "    v[\"image\"].save(f\"{save_ds_dir}/{i}.jpg\")\n",
    "    with open(f\"{save_ds_dir}/{i}.json\", \"w\") as f:\n",
    "        json.dump({\"prompt\": f'{pokemon_style_instruction} {v[\"en_text\"]}'}, f)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据集加载\n",
    "\n",
    "千帆SDK提供了数据集实现帮助我们可以快速的加载本地的数据集到内存，并通过设定DataSource数据源以保存至本地和千帆平台。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[INFO] [03-28 08:57:22] dataset.py:883 [t:8423316288]: list local dataset data by 0\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'image_path': '/Users/zhonghanjun/pywp/bce-qianfan-sdk/cookbook/finetune/pokemon_ds/63.jpg', 'annotation': {'prompt': 'pokemon, a drawing of a cat with a pink tail'}}\n"
     ]
    }
   ],
   "source": [
    "from qianfan.dataset import Dataset\n",
    "from qianfan.dataset.data_source import FileDataSource\n",
    "from qianfan.dataset.data_source.base import FormatType\n",
    "\n",
    "file_data_source = FileDataSource(path=save_ds_dir, file_format=FormatType.Text2Image)\n",
    "\n",
    "ds = Dataset.load(file_data_source)\n",
    "\n",
    "print(ds.list(0))"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从本地数据集上传到BOS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[INFO] [03-28 08:58:14] baidu_qianfan.py:451 [t:8423316288]: start to create dataset on qianfan\n",
      "[INFO] [03-28 08:58:15] baidu_qianfan.py:469 [t:8423316288]: create dataset on qianfan successfully\n",
      "[INFO] [03-28 08:58:17] baidu_qianfan.py:237 [t:8423316288]: start to upload data to user BOS\n",
      "[INFO] [03-28 08:58:17] baidu_qianfan.py:246 [t:8423316288]: upload dataset file /Users/zhonghanjun/pywp/bce-qianfan-sdk/cookbook/finetune/data_bfbc7896-57ab-448d-809f-d420873e2b8.zip to /sdk_ds/data_bfbc7896-57ab-448d-809f-d420873e2b85.zip\n",
      "[INFO] [03-28 08:58:20] baidu_qianfan.py:249 [t:8423316288]: uploading data to user BOS finished\n",
      "[INFO] [03-28 08:58:20] utils.py:520 [t:8423316288]: get shared file url: http://sdk-test.bj.bcebos.com/sdk_ds/data_bfbc7896-57ab-448d-809f-d420873e2b85.zip?authorization=bce-auth-v1%2FALTAKwzchhL7Obpsfk6MqV204I%2F2024-03-28T00%3A58%3A20Z%2F1800%2F%2F2856ab21db620a9c17f86cb9d1c7670117ac1974689b99644d4ac956244a5a25\n",
      "[INFO] [03-28 08:58:21] utils.py:479 [t:8423316288]: successfully create importing task\n",
      "[INFO] [03-28 08:58:23] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:24] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:26] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:26] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:28] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:29] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:31] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:31] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:33] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:34] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:36] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:36] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:38] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:39] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:41] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:41] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:43] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:44] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:46] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:46] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:48] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:48] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:50] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:51] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:53] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:53] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:55] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:56] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:58:58] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:58:58] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:00] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:00] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:02] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:03] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:05] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:05] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:07] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:08] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:10] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:10] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:12] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:13] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:15] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:15] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:17] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:18] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:20] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:20] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:22] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:22] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:24] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:25] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:27] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:27] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:29] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:29] utils.py:489 [t:8423316288]: import status: 1, keep polling\n",
      "[INFO] [03-28 08:59:31] utils.py:482 [t:8423316288]: polling import task status\n",
      "[INFO] [03-28 08:59:32] utils.py:492 [t:8423316288]: import succeed\n"
     ]
    }
   ],
   "source": [
    "# 保存到千帆平台\n",
    "from qianfan.dataset.data_source import QianfanDataSource\n",
    "from qianfan.resources.console import consts as console_consts\n",
    "\n",
    "bos_bucket_name = \"your_bucket_name\"\n",
    "bos_bucket_file_path = \"/sdk_ds/\"\n",
    "qianfan_dataset_name = \"random_train_t2i\"\n",
    "\n",
    "# 创建千帆数据集，并上传保存\n",
    "qianfan_data_source = QianfanDataSource.create_bare_dataset(\n",
    "    name=qianfan_dataset_name,\n",
    "    template_type=console_consts.DataTemplateType.Text2Image,\n",
    "    storage_type=console_consts.DataStorageType.PrivateBos,\n",
    "    storage_id=bos_bucket_name,\n",
    "    storage_path=bos_bucket_file_path,\n",
    ")\n",
    "\n",
    "ds = ds.save(qianfan_data_source)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 发起图生文训练\n",
    "这里我们选用`Stable-Diffusion-XL-Base-1.0`作为基础模型，"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "from qianfan.trainer.consts import PeftType\n",
    "\n",
    "trainer = Finetune(\n",
    "    train_type=\"Stable-Diffusion-XL-Base-1.0\",\n",
    "    train_config=TrainConfig(\n",
    "        peft_type=PeftType.LoRA,\n",
    "        batch_size=8,\n",
    "        epoch=20,\n",
    "        learning_rate=0.00005,\n",
    "    ),\n",
    "    dataset=ds,\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 运行任务\n",
    "同步运行trainer，训练直到模型发布完成"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[INFO] [03-28 09:04:53] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:04:55] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:04:58] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:00] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:03] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:05] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:07] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:10] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:12] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:15] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:17] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:20] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:22] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:25] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:27] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:30] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:32] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:34] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:37] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:39] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:42] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:44] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:47] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:49] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:52] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:54] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:57] utils.py:678 [t:8423316288]: data releasing, keep polling\n",
      "[INFO] [03-28 09:05:59] utils.py:685 [t:8423316288]: data releasing succeeded\n",
      "[INFO] [03-28 09:06:02] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 1% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:06:32] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 1% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:07:03] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 1% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:07:33] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 1% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:08:04] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 1% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:08:34] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 1% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:09:04] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 1% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:09:35] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 1% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:10:05] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 4% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:10:36] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:10:36] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:11:06] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:11:06] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:11:36] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:11:36] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:12:07] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:12:07] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:12:37] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:12:37] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:13:08] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:13:08] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:13:38] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:13:38] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:14:09] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:14:09] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:14:39] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:14:39] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:15:09] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:15:09] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:15:40] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:15:40] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:16:10] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:16:10] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:16:41] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:16:41] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:17:11] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:17:11] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:17:42] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:17:42] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:18:12] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:18:12] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:18:42] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:18:42] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:19:13] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:19:13] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:19:43] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:19:43] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:20:13] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:20:13] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:20:44] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:20:44] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:21:14] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:21:14] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:21:45] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:21:45] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:22:15] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:22:15] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:22:45] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:22:45] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:23:16] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:23:16] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:23:46] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:23:46] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:24:17] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:24:17] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:24:47] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:24:47] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:25:17] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:25:17] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:25:48] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:25:48] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:26:18] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:26:18] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:26:49] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:26:49] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:27:19] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:27:19] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:27:49] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:27:49] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:28:20] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:28:20] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:28:50] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:28:50] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:29:21] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:29:21] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:29:51] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:29:51] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:30:21] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:30:21] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:30:52] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:30:52] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:31:22] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:31:22] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:31:53] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:31:53] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:32:23] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:32:23] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:32:54] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:32:54] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:33:24] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:33:24] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:33:54] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:33:54] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:34:25] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:34:25] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:34:55] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:34:55] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:35:26] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:35:26] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:35:56] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:35:56] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:36:26] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:36:26] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:36:57] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:36:57] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:37:27] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:37:27] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:37:58] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:37:58] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:38:28] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:38:28] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:38:58] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:38:58] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:39:29] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:39:29] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:39:59] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:39:59] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:40:30] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:40:30] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:41:00] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:41:00] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:41:30] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:41:30] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:42:01] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:42:01] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:42:31] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:42:31] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:43:02] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:43:02] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:43:32] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:43:32] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:44:02] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 50% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:44:02] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:44:33] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 99% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:44:33] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:45:03] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 99% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:45:03] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:45:34] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 99% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:45:34] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:46:04] actions.py:561 [t:8423316288]: [train_action] training ... job_name:model07d874e1_BLqSw current status: Running, 99% check train task log in https://console.bce.baidu.com/qianfan/train/sft/job-ctqh9zinyezs/task-g5naerus77m1/detail/traininglog\n",
      "[INFO] [03-28 09:46:04] actions.py:568 [t:8423316288]:  check vdl report in https://console.bce.baidu.com/qianfan/visualdl/index?displayToken=eyJydW5JZCI6InJ1bi1ld25qdnBxamRrMXkwdTlwIn0=\n",
      "[INFO] [03-28 09:46:34] actions.py:538 [t:8423316288]: [train_action] training task metrics: {}\n",
      "[INFO] [03-28 09:46:34] actions.py:577 [t:8423316288]: [train_action] training job has ended: job-ctqh9zinyezs/task-g5naerus77m1 with status: Done\n",
      "[INFO] [03-28 09:46:34] model.py:217 [t:8423316288]: check train job: task-g5naerus77m1/job-ctqh9zinyezs status before publishing model\n",
      "[INFO] [03-28 09:46:34] model.py:230 [t:8423316288]: model publishing keep polling, current status Done\n",
      "[INFO] [03-28 09:46:36] model.py:262 [t:8423316288]: publishing train task: job-ctqh9zinyezs/task-g5naerus77m1 to model: am-g7kyg1pjak1e/amv-zgcskg9i4dcy\n",
      "[INFO] [03-28 09:47:06] model.py:287 [t:8423316288]: model am-g7kyg1pjak1e/amv-zgcskg9i4dcy published successfully\n",
      "[INFO] [03-28 09:47:06] model.py:267 [t:8423316288]: publish successfully to model: am-g7kyg1pjak1e/amv-zgcskg9i4dcy\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<qianfan.trainer.finetune.Finetune at 0x15f353510>"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trainer.run()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "获取finetune任务输出："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'datasets': {'sourceType': 'Platform',\n",
       "  'versions': [{'versionId': 'ds-ffvtnp0qznfpcitq'}],\n",
       "  'splitRatio': 20},\n",
       " 'task_id': 'task-g5naerus77m1',\n",
       " 'job_id': 'job-ctqh9zinyezs',\n",
       " 'metrics': {},\n",
       " 'model_id': 'am-g7kyg1pjak1e',\n",
       " 'model_version_id': 'amv-zgcskg9i4dcy',\n",
       " 'model': <qianfan.model.model.Model at 0x168b973d0>}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trainer.output"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用sdk发起部署流程，这一步需要到前端控制台进行支付才能完成："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[INFO] [03-28 14:57:02] model.py:484 [t:8423316288]: ready to deploy service with model am-g7kyg1pjak1e/amv-zgcskg9i4dcy\n",
      "[INFO] [03-28 14:57:06] model.py:519 [t:8423316288]: please check web console `https://console.bce.baidu.com/qianfan/ais/console/onlineService`,for service  deployment payment.\n",
      "[INFO] [03-28 14:57:36] model.py:519 [t:8423316288]: please check web console `https://console.bce.baidu.com/qianfan/ais/console/onlineService`,for service  deployment payment.\n",
      "[INFO] [03-28 14:58:07] model.py:519 [t:8423316288]: please check web console `https://console.bce.baidu.com/qianfan/ais/console/onlineService`,for service  deployment payment.\n",
      "[INFO] [03-28 14:58:37] model.py:519 [t:8423316288]: please check web console `https://console.bce.baidu.com/qianfan/ais/console/onlineService`,for service  deployment payment.\n",
      "[INFO] [03-28 14:59:07] model.py:519 [t:8423316288]: please check web console `https://console.bce.baidu.com/qianfan/ais/console/onlineService`,for service  deployment payment.\n",
      "[INFO] [03-28 14:59:37] model.py:519 [t:8423316288]: please check web console `https://console.bce.baidu.com/qianfan/ais/console/onlineService`,for service  deployment payment.\n",
      "[INFO] [03-28 15:00:08] model.py:519 [t:8423316288]: please check web console `https://console.bce.baidu.com/qianfan/ais/console/onlineService`,for service  deployment payment.\n"
     ]
    }
   ],
   "source": [
    "#-# cell_skip\n",
    "from qianfan.model import Service, Model\n",
    "from qianfan.model.consts import ServiceType\n",
    "from qianfan.resources.console.consts import DeployPoolType\n",
    "\n",
    "# 从训练结果中获取模型对象\n",
    "m: Model = trainer.output[\"model\"]\n",
    "\n",
    "sft_svc: Service = m.deploy(DeployConfig(\n",
    "    name=\"random_t2i_sdk\",\n",
    "    endpoint_suffix=\"sdpoke1\",\n",
    "    replicas=1, # 副本数， 与qps强绑定\n",
    "    pool_type=DeployPoolType.PrivateResource, # 私有资源池\n",
    "    service_type=ServiceType.Text2Image,\n",
    "    hours=1,\n",
    "))\n"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用Finetune之后的模型服务调用："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#-# cell_skip\n",
    "from qianfan.resources import Text2Image\n",
    "### 使用Model & Service调用模型\n",
    "problem=\"pokemon, a blue monkey with a hat\"\n",
    "\n",
    "#获取服务对象，即ChatCompletion等类型的对象\n",
    "t2i: qianfan.Text2Image = sft_svc.get_res()\n",
    "\n",
    "from PIL import Image \n",
    "import io\n",
    "resp = t2i.do(prompt=problem, with_decode=\"base64\")\n",
    "img_data = resp[\"body\"][\"data\"][0][\"image\"]\n",
    "\n",
    "img = Image.open(io.BytesIO(img_data))\n",
    "display(img)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.8"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "58f7cb64c3a06383b7f18d2a11305edccbad427293a2b4afa7abe8bfc810d4bb"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
